package nickthissen.iracing.datamodels;

import java.util.ArrayList;
import java.util.Arrays;

import com.google.gson.Gson;

public class Post
{
	public int Id;
	public String Author;
	public String AuthorUrl;
	public boolean AuthorOnline;
	public boolean AuthorDonated;
	public boolean AuthorIsStaff;
	public String Contents;
	public String PlainContents;
	public long CreatedTime;
	public String QuoteUrl;
	public String EditUrl;
	public boolean CanEdit;
    public boolean IsIgnored;
    public String IgnoredText;
    
    public static Post fromJson(String json)
    {
    	Gson g = new Gson();
    	PostDataModel data = g.fromJson(json, PostDataModel.class);
    	return data.d;
    }
    
    public static ArrayList<Post> getListFromJson(String json)
    {
    	Gson g = new Gson();
    	PostListDataModel data = g.fromJson(json, PostListDataModel.class);
    	return new ArrayList<Post>(Arrays.asList(data.d));
    }
    
    private class PostDataModel
    {
    	public Post d;
    }
    
    private class PostListDataModel
    {
    	public Post d[];
    }
}
